# 1编写：一个Python函数，用于计算一个数字(非负整数)的阶乘。函数接受数字作为参数
# 2 编写一个Python函数，该函数将一个数字作为参数，并检查该数字是否为素数(返回True or False)
# 3 编写一个Python函数，检查传递的字符串是否回文。

from functools import reduce
class HomeWork:

    YINZI_NUM = 10

    def __init__(self, num: int = 0, palindromestr: str = ""):
        self.num = num
        self.palindromestr = palindromestr

    def CalculationFactorial(self):
        return reduce(lambda x,y:x*y,range(1,abs(self.num)+1))

    def isPrimenumber(self):
        # 不能被其他自然数（质数）整除（2, 3, 5, 7等）
        if self.num == 1:
            return False
            
        for i in range(2,self.YINZI_NUM):
            if self.num == i:break
            if self.num % i == 0:
                return False
        return True 


    def isPalindrome(self):
        
       #偶数
        #字符串切割成俩部分，然后后面切割的字符串重新排序，最后比较俩个字符串如果等则是回文
        f_palindromeList = self.palindromestr[0:int(len(self.palindromestr)/2)]
        print('前',f_palindromeList)
        b_palindromeList = self.palindromestr[-int(len(self.palindromestr)/2):]
        new_palindrome = []
        new_str = ''
        
        for i in range(len(b_palindromeList)):
            new_palindrome.append(b_palindromeList[len(b_palindromeList)-i -1])

        print('list',new_palindrome)
        print('list join',new_str.join(new_palindrome))

        if new_str.join(new_palindrome) == f_palindromeList:
            return True
        else:
            return False
      


homework = HomeWork(3,"abcbbf")

print(homework.CalculationFactorial())
print(homework.isPalindrome())
#print(homework.isPrimenumber())

# nice！！